<template>
  <v-chart class="chart" :option="option" autoresize />
</template>

<script>
import { use } from "echarts/core";
import { CanvasRenderer } from "echarts/renderers";
import { RadarChart } from "echarts/charts";
import { TitleComponent, TooltipComponent, LegendComponent, RadarComponent } from "echarts/components";
import VChart from "vue-echarts";

use([CanvasRenderer, RadarChart, TitleComponent, TooltipComponent, LegendComponent, RadarComponent]);

export default {
  components: {
    VChart,
  },
  props: {
    data: {
      type: Object,
      required: true,
    },
  },
  computed: {
    option() {
      return {
        tooltip: {
          trigger: "item",
        },
        legend: {
          data: this.data.series.map((item) => item.name),
        },
        radar: {
          indicator: this.data.indicator,
          radius: "65%",
          splitNumber: 4,
          axisName: {
            color: "#666",
          },
          splitArea: {
            areaStyle: {
              color: ["rgba(24, 144, 255, 0.1)", "rgba(24, 144, 255, 0.05)"],
              shadowColor: "rgba(0, 0, 0, 0.1)",
              shadowBlur: 10,
            },
          },
          axisLine: {
            lineStyle: {
              color: "rgba(24, 144, 255, 0.3)",
            },
          },
          splitLine: {
            lineStyle: {
              color: "rgba(24, 144, 255, 0.3)",
            },
          },
        },
        series: [
          {
            name: "行为分析",
            type: "radar",
            data: this.data.series,
            areaStyle: {
              color: "rgba(24, 144, 255, 0.4)",
            },
            lineStyle: {
              width: 2,
            },
            symbolSize: 6,
          },
        ],
      };
    },
  },
};
</script>

<style scoped>
.chart {
  height: 350px;
}
</style>
